<template>
    <div class="example-container">
        <div class="card">
            <div class="title">登录接口: /api/app/basic-demo-12jasx/demo/login</div>
            <div><span>输入用户名：</span><input type="search" placeholder="请输入用户名" v-model="login.username"></div>
            <div><span>输入密码：</span><input type="search" placeholder="请输入密码" v-model="login.password"></div>
            <div>
                <button @click="login_(login)">测试</button>
            </div>
            <span>返回数据:</span>
            <textarea v-model="returndata.login" readonly></textarea>
        </div>
        <div class="card">
            <div class="title">用户列表分页接口: /api/app/basic-demo-12jasx/demo/pageUser</div>
            <div><span>输入页码：</span><input type="search" placeholder="请输入页码" v-model="pagenum"></div>
            <div>
                <button @click="pageUser_(pagenum)">测试</button>
            </div>
            <span>返回数据:</span>
            <textarea v-model="returndata.pageuser" readonly></textarea>
        </div>
        <div class="card">
            <div class="title">用户权限接口: /api/app/basic-demo-12jasx/demo/queryUserAcl</div>
            <div><span>输入应用码：</span><input type="search" placeholder="请输入应用码" v-model="appcode"></div>
            <div>
                <button @click="queryUserAcl_(appcode)">测试</button>
            </div>
            <span>返回数据:</span>
            <textarea v-model="returndata.queryuserAcl" readonly></textarea>
        </div>
        <div class="card">
            <div class="title">用户登录状态接口: /api/app/basic-demo-12jasx/demo/osLoginStatus</div>
            <div>
                <button @click="osLoginStatus_">测试</button>
            </div>
            <span>返回数据:</span>
            <textarea v-model="returndata.osloginstatus" readonly></textarea>
        </div>
    </div>
</template>

<script>
    import {login, queryUserAcl, pageUser, osLoginStatus} from "../../service/authority";

    export default {
        name: "index",
        data() {
            return {
                login: {
                    password: '', username: ''
                },
                pagenum: '',
                appcode: '',
                returndata: {
                    login: '',
                    queryuserAcl: '',
                    pageuser: '',
                    osloginstatus: ''
                }
            }
        },
        methods: {
            async login_(data) {
                try {
                    this.returndata.login = JSON.stringify(await login(data), null, 4)
                } catch (e) {
                    this.returndata.login = e
                }
            },
            async queryUserAcl_(data) {
                try {
                    this.returndata.queryuserAcl = JSON.stringify(await queryUserAcl(data), null, 4)
                } catch (e) {
                    this.returndata.queryuserAcl = e
                }
            },
            async pageUser_(data) {
                try {
                    this.returndata.pageuser = JSON.stringify(await pageUser(data), null, 4)
                } catch (e) {
                    this.returndata.pageuser = e
                }
            },
            async osLoginStatus_() {
                try {
                    this.returndata.osloginstatus = JSON.stringify(await osLoginStatus(), null, 4)
                } catch (e) {
                    this.returndata.osloginstatus = e
                }
            }
        }
    }
</script>
